# Scrapy settings for wangyiyun project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
#     https://docs.scrapy.org/en/latest/topics/settings.html
#     https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
#     https://docs.scrapy.org/en/latest/topics/spider-middleware.html
# 项目名字
BOT_NAME = 'wangyiyun'
# 让其他文件调用的标识
SPIDER_MODULES = ['wangyiyun.spiders']
NEWSPIDER_MODULE = 'wangyiyun.spiders'


# Crawl responsibly by identifying yourself (and your website) on the user-agent
# 用户代理
#USER_AGENT = 'wangyiyun (+http://www.yourdomain.com)'

# Obey robots.txt rules
# 机器人协议
ROBOTSTXT_OBEY = False

# Configure maximum concurrent requests performed by Scrapy (default: 16)
# 并发请求数量  默认16
# CONCURRENT_REQUESTS = 32

# Configure a delay for requests for the same website (default: 0)
# See https://docs.scrapy.org/en/latest/topics/settings.html#download-delay
# See also autothrottle settings and docs
# 下载延时操作  相当于time.sleep()
# DOWNLOAD_DELAY = 3
# The download delay setting will honor only one of:
# 在一个域之间的最大请求数
#CONCURRENT_REQUESTS_PER_DOMAIN = 16
# 单个ip每次的并发请求数量
#CONCURRENT_REQUESTS_PER_IP = 16


# Disable cookies (enabled by default)
# 重要的
# 1注释起来的时候不使用cookie  如果是post例外
# 2解开注释 为false 表示使用setting.py里面的默认cookie
# 3解开注释 为true 表示使用自定义cookie   post的cookie
COOKIES_ENABLED = True

# Disable Telnet Console (enabled by default)
#TELNETCONSOLE_ENABLED = False

# Override the default request headers:
# 默认的请求头
DEFAULT_REQUEST_HEADERS = {
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'Accept-Language': 'en',
    'Cookie': 'OUTFOX_SEARCH_USER_ID_NCOO=1593310827.8658907; OUTFOX_SEARCH_USER_ID=-590911363@10.108.162.134; DICT_UGC=be3af0da19b5c5e6aa4e17bd8d90b28a|; JSESSIONID=abcno1GMpANk7db_FX8ay; fanyi-ad-id=305566; fanyi-ad-closed=1; SESSION_FROM_COOKIE=unknown; ___rl__test__cookies=1650287148067',
    "Referer": "https://fanyi.youdao.com/"
}
# Enable or disable spider middlewares
# See https://docs.scrapy.org/en/latest/topics/spider-middleware.html
# 爬虫中间件
# SPIDER_MIDDLEWARES = {
#    'wangyiyun.middlewares.WangyiyunSpiderMiddleware': 543,
# }

# Enable or disable downloader middlewares
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
# 下载中间件  重点  重写爬取业务逻辑  添加代理
DOWNLOADER_MIDDLEWARES = {
   'wangyiyun.middlewares.WangyiyunDownloaderMiddleware': 543,
   'wangyiyun.middlewares.UseragentDownloaderMiddleware': 520,
}

# Enable or disable extensions
# See https://docs.scrapy.org/en/latest/topics/extensions.html
# 是否使用拓展程序
#EXTENSIONS = {
#    'scrapy.extensions.telnet.TelnetConsole': None,
#}

# Configure item pipelines
# See https://docs.scrapy.org/en/latest/topics/item-pipeline.html
# 管道 保存数据的位置
ITEM_PIPELINES = {
   'wangyiyun.pipelines.WangyiyunPipeline': 300,
}

# Enable and configure the AutoThrottle extension (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/autothrottle.html
#AUTOTHROTTLE_ENABLED = True
# The initial download delay
# 开始的下载时的第一下下载延时
#AUTOTHROTTLE_START_DELAY = 5
# The maximum download delay to be set in case of high latencies
# 最大延迟时间
#AUTOTHROTTLE_MAX_DELAY = 60
# The average number of requests Scrapy should be sending in parallel to
# each remote server
#AUTOTHROTTLE_TARGET_CONCURRENCY = 1.0
# Enable showing throttling stats for every response received:
#AUTOTHROTTLE_DEBUG = False

# Enable and configure HTTP caching (disabled by default)
# See https://docs.scrapy.org/en/latest/topics/downloader-middleware.html#httpcache-middleware-settings
#HTTPCACHE_ENABLED = True
#HTTPCACHE_EXPIRATION_SECS = 0
#HTTPCACHE_DIR = 'httpcache'
#HTTPCACHE_IGNORE_HTTP_CODES = []
#HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
